<template>
  <div class="home-main">
    <div class="banner-wrapper">
      <a-carousel autoplay v-if="indexPic.bannerList.length">
        <div
          v-for="(item, index) in indexPic.bannerList"
          :key="index"
          style="cursor: pointer"
        >
          <img @click="open(item.url)" :src="apiUrl + item.image" />
        </div>
      </a-carousel>
    </div>

    <div class="brand-wrapper">
      <div class="card-title">品牌企业</div>
      <div class="brand-list">
        <div
          class="brand-item"
          v-for="item in indexPic.brand_com"
          :key="item.ID"
          @click="open(item.url)"
        >
          <img :src="apiUrl + item.pic" />
        </div>
      </div>
    </div>

    <div class="industry-wrapper">
      <div class="card-title">按行业浏览</div>
      <div class="industry-list">
        <div
          class="industry-item"
          v-for="item in industrys"
          :key="item.title"
          @click="$router.push(item.path)"
        >
          <div class="item-left">
            <div class="title">{{ item.title }}</div>
            <div class="desc">{{ item.desc }}</div>
          </div>

          <img :src="item.pic" />
        </div>
      </div>
    </div>

    <div class="company-wrapper">
      <div class="card-title">合作企业</div>

      <div class="company-list">
        <div
          class="company-item"
          v-for="item in indexPic.coop_com"
          :key="item.name"
          @click="open(item.url)"
        >
          <div class="pic-wrapper">
            <img :src="apiUrl + item.pic" />
          </div>
          <div class="name">{{ item.name }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // indexPic: {
      //   bannerList: [],
      //   brand_com: [],
      //   coop_com: [],
      //   coop_com_two: []
      // },
      industrys: [
        {
          pic: require("./images/industry1.png"),
          title: "主材",
          path: "/business?cWork=主材",
          desc: "水泥/钢筋/混凝土 ... >"
        },
        {
          pic: require("./images/industry2.png"),
          title: "地材",
          path: "/business?cWork=地材",
          desc: "砂/石/墙砖 ... >"
        },
        {
          pic: require("./images/industry3.png"),
          title: "机械",
          path: "/business?cWork=机械",
          desc: "建筑机械/工程机械 ... >"
        },
        {
          pic: require("./images/industry4.png"),
          title: "辅材",
          path: "/business?cWork=辅材",
          desc: "柴油/机油/轮胎 ... >"
        },
        {
          pic: require("./images/industry5.png"),
          title: "分包",
          path: "/business?cWork=分包",
          desc: "桩机/土石方/幕墙 ... >"
        },
        {
          pic: require("./images/industry6.png"),
          title: "服务/法律",
          path: "/business?cWork=服务/法律",
          desc: "建筑相关服务/法律 ... >"
        }
      ],
      companys: [
        {
          pic: require("./images/company1.png"),
          name: "厦门市集美区鸿铭建材",
          path: "https://www.11467.com/qiye/27591841.htm"
        },
        {
          pic: require("./images/company2.png"),
          name: "福建腾鲲建筑劳务工程有限公司",
          path: "https://www.11467.com/xiamen/co/195416.htm"
        },
        {
          pic: require("./images/company3.png"),
          name: "中建协筑建材",
          class: "company",
          path: "http://zjxzscm.com/"
        },
        {
          pic: require("./images/company4.png"),
          name: "厦门海奥集团",
          path: "http://www.xmhaiao.cn"
        },
        {
          pic: require("./images/company5.png"),
          name: "厦门华特集团",
          path: "http://www.xmhuate.com"
        },
        {
          pic: require("./images/company6.png"),
          name: "河南砼鑫软件",
          path: "https://www.hntxrj.com"
        },
        {
          pic: require("./images/company7.png"),
          name: "厦门市新鹭发土石方",
          path: "http://www.likuso.com/city242/496627.html"
        },
        {
          pic: require("./images/company8.png"),
          name: "福建省永安万年水泥",
          path: "http://909899.b2b.tfsb.cn"
        }
      ]
    };
  },
  mounted() {
    this.getIndexPic();

    for (let i = 0; i < this.config.c_types.length; i++) {
      this.industrys[i].pic = this.config.c_types[i].pic;
      this.industrys[i].title = this.config.c_types[i].name;
      this.industrys[i].desc = "";
      for (let j = 0; j < this.config.c_types[i].c_types.length; j++) {
        this.industrys[i].desc += this.config.c_types[i].c_types[j].name + "/";
      }
    }
  },
  methods: {
    open(url) {
      window.open(url);
    }
  }
};
</script>

<style lang="less" scoped>
.home-main {
  .banner-wrapper {
    display: block;
    width: 100%;

    img {
      display: block;
    }
  }

  .card-title {
    font-size: 20px;
    &::before {
      background: #ff7752;
    }
  }

  .brand-wrapper {
    background: @white;
    margin-top: 14px;
    padding: 24px 20px;

    .brand-list {
      display: flex;
      padding: 16px 0;
      align-items: center;
      cursor: pointer;
      flex-wrap: wrap;

      .brand-item {
        width: 33.33%;
        padding: 10px 8px;
        text-align: center;
        cursor: pointer;

        img {
          max-height: 80px;
          object-fit: cover;
        }
      }
    }
  }

  .industry-wrapper {
    background: @white;
    margin-top: 16px;
    padding: 24px 20px;
    .industry-list {
      display: flex;
      flex-wrap: wrap;
      margin-top: 8px;

      .industry-item {
        display: flex;
        padding: 13px 12px;
        cursor: pointer;
        width: 50%;
        align-items: center;
        border-bottom: 1px dashed @text-color-3;

        .item-left {
          flex: 1;
          color: @text-color-1;

          .title {
            font-size: 18px;
            font-weight: bold;
          }

          .desc {
            font-size: 15px;
            margin-top: 4px;
          }
        }

        img {
          width: 60px;
          margin-right: 40px;
        }
      }
    }
  }

  .company-wrapper {
    background: @white;
    margin-top: 16px;
    padding: 24px 20px;

    .company-list {
      margin-top: 20px;
      padding: 0 8px;
      display: flex;
      flex-wrap: wrap;
      .company-item {
        width: 25%;
        text-align: center;
        cursor: pointer;
        padding: 4px 18px;

        .pic-wrapper {
          width: 78px;
          height: 78px;
          margin: auto;
          line-height: 78px;
        }

        .name {
          font-size: 15px;
          color: @text-color-2;
          margin-top: 12px;
        }
      }
    }
  }
}
</style>
